package com.ellecity06.common.widgets.touch

import android.content.Context
import android.util.AttributeSet
import android.view.MotionEvent
import androidx.appcompat.widget.AppCompatImageView
import com.hjq.shape.view.ShapeImageView

/**
 * @author ellecity06
 * @time 2025/3/28 15:25
 * @des
 */
class DragZoomImageView @JvmOverloads constructor(
    context: Context?,
    attrs: AttributeSet? = null,
    defStyleAttr: Int = 0
) : ShapeImageView(context!!, attrs, defStyleAttr) {
    private var dragZoomRotateHelper: DragZoomRotateHelper? = null

    init {
        dragZoomRotateHelper = DragZoomRotateHelper(this)

    }

    override fun onTouchEvent(event: MotionEvent): Boolean {
        if (dragZoomRotateHelper == null) return super.onTouchEvent(event)
        return dragZoomRotateHelper!!.onTouchEvent(event)
    }

    override fun onLayout(changed: Boolean, left: Int, top: Int, right: Int, bottom: Int) {
        super.onLayout(changed, left, top, right, bottom)
        dragZoomRotateHelper?.onLayout(changed, left, top, right, bottom)
    }
}